package com.finger.crowd.util;

import java.io.Serializable;

public class ResultEntity<T> implements Serializable {

    private static final String SUCCESS = "SUCCESS";
    private static final String FAILED = "FAILED";
    //    是否接收成功
    private String result;
    //    返回的数据
    private T data;
    //    异常信息
    private String massage;

    public static String getSUCCESS() {
        return SUCCESS;
    }

    public static String getFAILED() {
        return FAILED;
    }

    public static <Type> ResultEntity<Type> successWithOutData() {
        return new ResultEntity(SUCCESS, null, null);
    }

    public static <Type> ResultEntity<Type> successWithData(Type type) {
        return new ResultEntity<Type>(SUCCESS, type, null);
    }

    public static <Type> ResultEntity<Type> failed(String msg) {
        return new ResultEntity<Type>(FAILED, null, msg);
    }

    public ResultEntity(String result, T data, String massage) {
        this.result = result;
        this.data = data;
        this.massage = massage;
    }

    public ResultEntity() {
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String result() {
        return result;
    }

    public void setSuccess(String success) {
        result = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    @Override
    public String toString() {
        return "ResultEntity{" +
                "result='" + result + '\'' +
                ", data=" + data +
                ", massage='" + massage + '\'' +
                '}';
    }
}
